package cn.jhc;

public class Game {
    private int currentFrame = 1;
    private boolean isFirstThrow = true;
    private Scorer scorer = new Scorer();

    public void add(int pins) {
        scorer.addThrow(pins);
        adjustCurrentFrame(pins);
    }

    private void adjustCurrentFrame(int pins) {
        if (isFirstThrow) {
            if (pins == 10) {
                currentFrame++;
            } else {
                isFirstThrow = false;
            }
        } else {
            isFirstThrow = true;
            currentFrame++;
        }
        currentFrame = Math.min(11, currentFrame);
    }

    public int getScore() {
        return getScoreForFrame(getCurrentFrame() - 1);
    }

    public int getScoreForFrame(int frame) {
        return scorer.getScoreForFrame(frame);
    }


    public int getCurrentFrame() {
        return currentFrame;
    }
}
